package cn.iocoder.yudao.module.vote.dal.mysql.voteuserinfo;

import java.util.*;

import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.vote.dal.dataobject.voteuserinfo.VoteUserInfoDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.vote.controller.admin.voteuserinfo.vo.*;

/**
 * 投票用户信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface VoteUserInfoMapper extends BaseMapperX<VoteUserInfoDO> {

    default PageResult<VoteUserInfoDO> selectPage(VoteUserInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VoteUserInfoDO>()
                .likeIfPresent(VoteUserInfoDO::getUserName, reqVO.getUserName())
                .eqIfPresent(VoteUserInfoDO::getUserNick, reqVO.getUserNick())
                .eqIfPresent(VoteUserInfoDO::getUserNo, reqVO.getUserNo())
                .eqIfPresent(VoteUserInfoDO::getUnit, reqVO.getUnit())
                .likeIfPresent(VoteUserInfoDO::getPosition, reqVO.getPosition())
                .eqIfPresent(VoteUserInfoDO::getUserLevel, reqVO.getUserLevel())
                .likeIfPresent(VoteUserInfoDO::getMobile, reqVO.getMobile())
                .eqIfPresent(VoteUserInfoDO::getSex, reqVO.getSex())
                .eqIfPresent(VoteUserInfoDO::getIsDisable, reqVO.getIsDisable())
                .eqIfPresent(VoteUserInfoDO::getRemark, reqVO.getRemark())
                .likeIfPresent(VoteUserInfoDO::getDepartment, reqVO.getDepartment())
                .eqIfPresent(VoteUserInfoDO::getWeight, reqVO.getWeight())
                .eqIfPresent(VoteUserInfoDO::getShortDpm, reqVO.getShortDpm())
                .betweenIfPresent(VoteUserInfoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(VoteUserInfoDO::getWeight));
    }

    default List<VoteUserInfoDO> selectList(VoteUserInfoExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<VoteUserInfoDO>()
                .likeIfPresent(VoteUserInfoDO::getUserName, reqVO.getUserName())
                .eqIfPresent(VoteUserInfoDO::getUserNick, reqVO.getUserNick())
                .eqIfPresent(VoteUserInfoDO::getUserNo, reqVO.getUserNo())
                .eqIfPresent(VoteUserInfoDO::getUnit, reqVO.getUnit())
                .eqIfPresent(VoteUserInfoDO::getPosition, reqVO.getPosition())
                .eqIfPresent(VoteUserInfoDO::getUserLevel, reqVO.getUserLevel())
                .eqIfPresent(VoteUserInfoDO::getMobile, reqVO.getMobile())
                .eqIfPresent(VoteUserInfoDO::getSex, reqVO.getSex())
                .eqIfPresent(VoteUserInfoDO::getIsDisable, reqVO.getIsDisable())
                .eqIfPresent(VoteUserInfoDO::getRemark, reqVO.getRemark())
                .eqIfPresent(VoteUserInfoDO::getDepartment, reqVO.getDepartment())
                .eqIfPresent(VoteUserInfoDO::getWeight, reqVO.getWeight())
                .eqIfPresent(VoteUserInfoDO::getShortDpm, reqVO.getShortDpm())
                .betweenIfPresent(VoteUserInfoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(VoteUserInfoDO::getId));
    }

    default VoteUserInfoDO selectByMobile(String mobile) {
        return selectOne(new LambdaQueryWrapper<VoteUserInfoDO>().eq(VoteUserInfoDO::getMobile, mobile));
    }

}
